home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / unix / mp14tar.z / mp14tar / mpack / macnapp.h < prev    next >
C/C++ Source or Header  |  1994-06-01  |  21KB  |  523 lines

  1. /* mac_napp.h -- general mac application library header
  2.  *
  3.  * (C) Copyright 1990, 1991 by Christopher J. Newman
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of Christopher J. Newman not be used in
  11.  * advertising or publicity pertaining to distribution of the software without
  12.  * specific, written prior permission.  Christopher J. Newman makes no
  13.  * representations about the suitability of this software for any purpose.  It
  14.  * is provided "as is" without express or implied warranty.
  15.  *
  16.  * CHRISTOPHER J. NEWMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  17.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  18.  * SHALL CHRISTOPHER J. NEWMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  19.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  20.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  21.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  22.  * OF THIS SOFTWARE.
  23.  *
  24.  * Author:    Christopher J. Newman
  25.  * Message:    This is a nifty program.
  26.  *
  27.  * - Trouble opening window in init proc of other window
  28.  */
  29.  
  30. #ifdef THINK_C
  31. #define QD(x)    (x)
  32. #ifndef NULL
  33. #define NULL    0
  34. #endif
  35. #else
  36. #define QD(x)    (qd.x)
  37. #include <MacTypes.h>
  38. #include <Quickdraw.h>
  39. #include <Events.h>
  40. #include <Controls.h>
  41. #include <Windows.h>
  42. #include <MemoryMgr.h>
  43. #include <Menus.h>
  44. #include <OSUtils.h>
  45. #include <TextEdit.h>
  46. #include <Dialogs.h>
  47. #endif
  48.  
  49. /* implicit void * types.
  50.  */
  51. typedef void **HANDLE;
  52. typedef void *PTR;
  53.  
  54. /* dual pascal/C strings
  55.  */
  56. typedef unsigned char PCstr;
  57. #define C(str)    ((char*)(str) + 1)
  58. #define P(str)    ((unsigned char*)(str))
  59.  
  60. /* SBYTE is supplied for non-char signed bytes.
  61.  */
  62. typedef unsigned short WORD;
  63. typedef unsigned long DWORD;
  64. typedef unsigned char BYTE;
  65. typedef char SBYTE;
  66.  
  67. /* useful macros:
  68.  */
  69. #define ABS(x)        ( (x) < 0 ? -(x) : (x) )
  70. #define SGN(x)        ( (x) < 0 ? -1 : 1 )
  71. #ifndef MIN
  72. #define MIN(m,n)    ( (n) < (m) ? (n) : (m) )
  73. #define MAX(m,n)    ( (n) > (m) ? (n) : (m) )
  74. #endif
  75. #define HIBYTE(x)    ( (BYTE) ((x) >> 8) )
  76. #define LOBYTE(x)    ( (BYTE) (x) )
  77. #define HIWORD(x)    ( (WORD) ( (x) >> 16) )
  78. #define LOWORD(x)    ( (WORD) (x) )
  79.  
  80. /* all window/menu procedures return short integers (see defines below)
  81.  */
  82. typedef short (*na_menup)(struct na_win *, WORD, WORD);
  83. typedef short (*na_mousep)(struct na_win *, Point, short, short);
  84. typedef short (*na_ctrlp)(struct na_win *, Point, short, short, ControlHandle);
  85. typedef short (*na_activep)(struct na_win *, Boolean);
  86. typedef short (*na_closep)(struct na_win *);
  87. typedef short (*na_updatep)(struct na_win *, Boolean);
  88. typedef short (*na_keyp)(struct na_win *, long, short);
  89. typedef short (*na_cursorp)(struct na_win *, Point);
  90. typedef short (*na_miscp)(struct na_win *, EventRecord *);
  91. typedef short (*na_idlep)(struct na_win *);
  92. typedef short (*na_taskp)(struct na_win *);
  93. typedef short (*na_resizep)(struct na_win *, Point, Rect *);
  94. typedef short (*na_openp)(short, AppFile *, FSSpec *);
  95. typedef short (*na_initp)(struct na_win *, long *);
  96. typedef struct na_win {
  97.     long            flags;        /* flags indicating various window settings (see below) */
  98.     short            delay;        /* delay between main loop cycles (in ticks) */
  99.     short            mousepix;    /* number of pixels mouse can move until drag starts */
  100.     short            minw, minh;    /* minimum width and height for the window */
  101.     short            maxw, maxh;    /* maximum width and height for the window */
  102.     short            type;        /* current window type (negatives reserved) */
  103.     BYTE            locks;        /* locks on this window structure */
  104.     BYTE            priority;    /* priority if there is a taskp */
  105.     RgnHandle        cursorRgn;    /* cursor region */
  106.     RgnHandle        uncrsrRgn;    /* region cursor isn't in */
  107.     WindowPtr        pwin;        /* window pointer */
  108.     struct na_win    **next;        /* handle to next window in linked list */
  109.     struct na_win    **task;        /* handle to next task in a linked list of active tasks */
  110.     struct na_win    **child;    /* handle to child window list (NULL = no child) */
  111.     struct na_win    **parent;    /* handle to parent window (NULL = toplevel) */
  112.     na_menup        menup;        /* menu proc */
  113.     na_mousep        mousep;        /* mouse proc */
  114.     na_ctrlp        ctrlp;        /* dialog item/control proc */
  115.     na_activep        activep;    /* activate proc */
  116.     na_closep        closep;        /* close proc */
  117.     na_updatep        updatep;    /* update proc */
  118.     na_keyp            keyp;        /* key proc */
  119.     na_cursorp        cursorp;    /* cursor setting proc */
  120.     na_miscp        miscp;        /* miscellaneous event proc (disk/net/app/driver) */
  121.     na_idlep        idlep;        /* idle proc */
  122.     na_taskp        taskp;        /* task proc */
  123.     na_resizep        resizep;    /* resize proc */
  124.     long            resid;        /* storage for window resource id or user data. */
  125.     char            *data;        /* data pointer for user */
  126. } na_win;
  127. typedef struct nate_win {
  128.     na_win            winp;
  129.     TEHandle        hTE;        /* textedit handle for auto-textedit routines */
  130.     ControlHandle    hctrl;        /* horizontal scroll bar for textedit */
  131.     ControlHandle    vctrl;        /* vertical scroll bar for textedit */
  132.     long            docwidth;    /* width of the document */
  133.     short            lheight;    /* line height of text */
  134. } nate_win;
  135. /* procedures types:
  136.  *
  137.  * // called for menu events when window is frontmost
  138.  * // supercedes global menu function unless NA_NOTPROCESSED is returned.
  139.  * // if menuid is 0, the procedure should enable/disable menus appropriately
  140.  * // if menuid is 1, the procedure should disable enabled menus appropriately
  141.  * short menu(winp, menuid, itemno)
  142.  *    WORD menuid;            // resource id of the menu
  143.  *    WORD itemno;            // item number of the menu item
  144.  *
  145.  * // called for mouse down/up/move events in the window
  146.  * short mouse(winp, p, type, mods)
  147.  *    Point p;                // location of mouse action
  148.  *    short type;                // type of mouse action (see below)
  149.  *    short mods;                // modifier keys
  150.  *
  151.  * // called for dialog events in dialog windows
  152.  * // control events in windows with controls
  153.  * // In a dialog window with no key procedure, ESC, command-., return, enter are
  154.  * // mapped to iCancel and iOk.
  155.  * short control(winp, p, itemHit, mods, ctrlh)
  156.  *    Point p;                // point in window local coords
  157.  *    short itemHit;            // the item/part code clicked
  158.  *    short mods;                // modifier keys
  159.  *    ControlHandle ctrlh;    // handle to the control
  160.  *
  161.  * // called when window is activated or deactivated
  162.  * // close return values may be ignored on a deactivate
  163.  * short activate(winp, on)
  164.  *    Boolean on;                // true = activate, false = deactivate
  165.  *
  166.  * // called when a window close request has been made (close box/close menu item)
  167.  * // called when any window function returns NA_REQCLOSE or NA_REQCLOSEALL
  168.  * // respond with either NA_CLOSED or NA_NOTPROCESSED
  169.  * short close(winp)
  170.  *
  171.  * // called on update events
  172.  * short update(winp, newsize)
  173.  *    Boolean newsize;        // true if r is a new window size
  174.  *
  175.  * // called on key/autokey events (menu keys are parsed out first)
  176.  * short key(winp, c, mods)
  177.  *    long c;                    // ASCII value of the key (unless NA_RAWKEY option set)
  178.  *    short mods;                // modifier keys
  179.  *
  180.  * // called when cursor moves into or out of a window
  181.  * // use winp->flags & NA_CURSORON
  182.  * // close request return values are ignored.
  183.  * // return NA_PROCESSED only when the cursorRgn is changed
  184.  * short cursor(winp, p)
  185.  *    Point p;                // point where the cursor is
  186.  *
  187.  * // This is called for miscellaneous events (disk/network/driver/app1-3)
  188.  * short miscp(winp, pevent)
  189.  *    EventRecord *pevent;    // the event
  190.  *
  191.  * // called every time through the event loop when window active
  192.  * short idle(winp)
  193.  *
  194.  * // called cyclicly with other tasks with each pass through event loop
  195.  * // only used when task is installed
  196.  * // the task procedure can only close it's own window.
  197.  * short task(winp)
  198.  *
  199.  * // function called to resize the window 
  200.  * // (parameters similar to GrowWindow function)
  201.  * short resize(winp, where, rct)
  202.  *  Point where;
  203.  *  Rect *rct;
  204.  *
  205.  * // function passed to NAinit:
  206.  * // should return 0 if OK, and -1 to stop opening files
  207.  * short open(message, afile, fspec)
  208.  *    short message;            // either appOpen or appPrint (in SegLoad.h)
  209.  *  AppFile *afile;            // file to open/print (if NULL, use fspec)
  210.  *  FSSpec *fspec;            // file to open/print (if NULL, use afile)
  211.  *
  212.  * // function passed to NAwindow:
  213.  * // returns standard window status
  214.  * short init(winp, datap)
  215.  *    na_win    *winp;            // pointer to new window structure
  216.  *    long    *datap;            // pointer to data passed through NAwindow
  217.  */
  218.  
  219. /* niftyapp globals */
  220. extern na_win **NAhead;        /* handle to the head of the window tree */
  221. extern na_win **NAtask;        /* handle to the head of the window task list */
  222. extern na_win **NActask;    /* handle to the current task */
  223. extern na_win *NAwin;        /* pointer to current window (NULL = no current window) */
  224. extern na_menup NAmenup;    /* pointer to default menu procedure */
  225. extern short NAnewitem;        /* item number of the new item on the file menu (0 = not avail) */
  226. extern short NAcloseitem;    /* item number of the close item on the file menu (0 = not avail) */
  227. extern short NAappleitems;    /* the number of items at the top of the apple menu */
  228. extern Boolean NAhasedit;    /* true if application has an edit menu */
  229. extern long NAdelay;        /* the wait next event delay */
  230. extern SysEnvRec NAsysenv;    /* mac system environment */
  231. extern Boolean NAinBack;    /* true if application is backgrounded */
  232. extern long NAmousetime;    /* time of last mouse up event */
  233. extern short NAlastmouse;    /* kind of last mouse event */
  234. extern Cursor NAibeam;        /* the ibeam cursor */
  235. extern long NAgestaltBits;  /* 0 = gestalt not on system */
  236.  
  237. /* globals for your convenience */
  238. extern RgnHandle NAfullRgn, NAnullRgn;
  239.  
  240. /* niftyapp definitions */
  241.  
  242. /* default resource id for niftyapp windows */
  243. #define NA_CLIPWINDOW    1000
  244. #define NA_DEBUGWINDOW    1001
  245. /* default resource id for menu bar */
  246. #define NA_MBAR            128
  247. /* default item numbers for OK & cancel */
  248. #define iOk                1
  249. #define iCancel            2
  250. /* default resource ids for APPLE, FILE, and EDIT menus */
  251. #define mApple            128
  252. #define mFile            129
  253. #define mEdit            130
  254. /* default item numbers for edit menu */
  255. #define iUndo            1
  256. #define iCut            3
  257. #define iCopy            4
  258. #define iPaste            5
  259. #define iClear            6
  260. #define iSelAll            8
  261. #define iClipboard        9
  262. /* new window positions */
  263. #define NA_HFULLSCN        0x0000
  264. #define NA_HQUARTERSCN    0x0001
  265. #define NA_HHALFSCN        0x0002
  266. #define NA_H3QUARTERSCN    0x0003
  267. #define NA_VFULLSCN        0x0000
  268. #define NA_VQUARTERSCN    0x0004
  269. #define NA_VHALFSCN        0x0008
  270. #define NA_V3QUARTERSCN    0x000C
  271. #define NA_CENTERSCN    0x0000
  272. #define NA_TOPSCN        0x0010
  273. #define NA_BOTTOMSCN    0x0020
  274. #define NA_LEFTSCN        0x0040
  275. #define NA_RIGHTSCN        0x0080
  276. #define NA_STACK        0x0100
  277. #define NA_TITLEOFFSET    0x0200
  278. /* new window flags */
  279. #define NA_PLAINWIN        0x00000000L    /* plain window -- no title, simple border */
  280. #define NA_COLORWINDOW    0x00000001L    /* allow color in the window */
  281. #define NA_DIALOGWINDOW    0x00000002L    /* open as a dialog */
  282. #define NA_TITLEBAR        0x00000004L    /* have title bar */
  283. #define NA_GROWBOX        0x00000008L    /* have a grow box (enables automatic drawing) */
  284. #define NA_ZOOMBOX        0x00000010L    /* have a zoom box */
  285. #define NA_CLOSEBOX        0x00000020L    /* have a close box (enables close menu item) */
  286. #define NA_SHADOWBORDER    0x00000040L    /* have a shadow border (for dialogs) */
  287. #define NA_DOUBLEBORDER    0x00000080L    /* have a double (dialog) border */
  288. #define NA_ROUNDBORDER    0x000000c0L    /* have rounded corners and black title bar */
  289. #define NA_CHILDWINDOW    0x00000100L    /* open as a child window of current window */
  290. #define NA_NOTVISIBLE    0x00000200L    /* do not make window visible on open */
  291. #define NA_BEHIND        0x00000400L    /* open window behind current window */
  292. #define NA_HASCONTROLS    0x00000800L    /* process/draw/kill controls automatically */
  293. #define NA_HASTASK        0x00001000L    /* install window in background task list */
  294. #define NA_USERESOURCE    0x00002000L    /* use res parameter as WIND/DLOG/wctb/dctb resource */
  295. #define NA_CURSORON        0x00004000L    /* true if application has set the cursor */
  296. #define NA_MODAL        0x00008000L    /* set if window/dialog will be modal */
  297. #define NA_DIALOGUPDATE    0x00010000L    /* UpdtDialog will be called */
  298. #define NA_DEFBUTTON    0x00020000L    /* show default button after init proc */
  299. #define NA_COPYDATA        0x00040000L    /* data will by copied by NAwindow */
  300. #define NA_SMARTSIZE    0x00080000L    /* window resizes & placements are saved in WIND res */
  301. #define NA_RECENTER        0x00100000L    /* don't force size, just recenter window */
  302. #define NA_FORCESIZE    0x00200000L    /* when a resource is used, re-size the window anyway */
  303. #define NA_RAWKEY        0x00400000L    /* if set, key event fields aren't stripped */
  304. #define NA_HILITECTRLS    0x00800000L    /* if set, hilite controls on activate/deactive */
  305. #define NATE_FLAGS        0x0f000000L    /* flags reserved for NATE */
  306. #define NA_USER_FLAG1    0x10000000L    /* flags reserved for users */
  307. #define NA_USER_FLAG2    0x20000000L
  308. #define NA_USER_FLAG3    0x40000000L
  309. #define NA_USER_FLAG4    0x80000000L
  310. /* niftyapp window types */
  311. #define NA_CLIPTYPE        -1
  312. #define NA_DEBUGTYPE    -2
  313. /* mouse click types */
  314. #define NA_DOWN1        0
  315. #define NA_UP1            1
  316. #define NA_DOWN2        2
  317. #define NA_UP2            3
  318. #define NA_DOWNN        4
  319. #define NA_UPN            5
  320. #define NA_DRAG            6
  321. #define NA_RELEASE        7
  322. /* return values for window/menu procedures */
  323. #define NA_ALLCLOSED    -4        /* all windows are to be destroyed & exit app immediately */
  324. #define NA_REQCLOSEALL    -3        /* request to close all windows & exit app */
  325. #define NA_CLOSED        -2        /* current window is ready to close (used by closep/taskp) */
  326. #define NA_REQCLOSE        -1        /* request to close current window */
  327. #define NA_NOTPROCESSED    0        /* use any default handler available */
  328. #define NA_PROCESSED    1        /* do nothing more */
  329. #define NA_DPROCESSED    2        /* don't do key -> button translation on a dialog */
  330. /* Gestalt bits */
  331. #define NA_HASGESTALT    0x00000001L    /* Gestalt available */
  332. #define NA_HASAEVENTS    0x00000002L    /* Apple events supported */
  333.  
  334. /* niftyapp macros */
  335.  
  336. #define NAunlockWindow(winp)        {if (!--(winp)->locks) HUnlock((Handle) GetWRefCon((winp)->pwin));}
  337. #define NAunlockWindowh(winh, winp)    {if (!--(winp)->locks) HUnlock((Handle) winh);}
  338. #define NAisDAWindow(pWnd)            (( (WindowPeek) pWnd)->windowKind < 0)
  339. #define NAenableMItem(menu, item)    EnableItem(GetMHandle(menu), item)
  340. #define NAdisableMItem(menu, item)    DisableItem(GetMHandle(menu), item)
  341. #define NAcheckItem(menu, item, c)    CheckItem(GetMHandle(menu), item, c)
  342. #define NAgetDHandle(dlg, it, hn)    {short ty; Rect r; GetDItem(dlg, it, &ty, (Handle *) (hn), &r);}
  343. #define NAgetDRect(dlg, it, rct)    {short ty; Handle hn; GetDItem(dlg, it, &ty, &hn, (rct));}
  344. #define NAsetInum(dlg, it, val)        NAsetIText(dlg, it, longtoPCstr(val))
  345. #define NAalert(resid)                Alert(resid, NAfilterProc)
  346.  
  347. /* niftyapp procedures */
  348.  
  349. /* initialize the Macintosh managers and niftyapp internal variables.
  350.  * optionally set up a menu bar & menu procedure.
  351.  * Returns 0 if OK, negative if an error occured, 1 if print files requested & app should quit
  352.  * short minK;            // minimum K needed to execute
  353.  * short masters;        // number of times to call MoreMasters()
  354.  * na_proc *openp;        // open file procedure -- called for each application in the startup list
  355.  * na_proc *menup;        // pointer to a menu procedure (NULL = no menu handling)
  356.  * short numapple;        // number of apple menu items
  357.  * short newitem;        // item number of new item
  358.  * short closeitem;        // item number of close item
  359.  */
  360. short NAinit(short, short, na_openp, na_menup, short, short, short);
  361.  
  362. /* call the main loop procedure
  363.  */
  364. void NAmainloop(void);
  365.  
  366. /* create a rectangle based on the screen size
  367.  *    short position;        // see above
  368.  */
  369. Rect *NAscreenrect(short);
  370.  
  371. /* create a new window structure
  372.  * returns window status result, up to the caller to pass on NA_ALLCLOSED
  373.  *    Rect *rpos;            // placement rectangle
  374.  *    long flags;            // flags determining type of window
  375.  *    char *title;        // window title (C string may not be NULL unless NA_USERESOURCE)
  376.  *    short res;            // resource number of WIND/DLOG/wctb/dctb/DITL
  377.  *    long *initdata;        // window data (may be NULL)
  378.  *    long datasize;        // bytes of window data
  379.  *    na_proc *initp;        // procedure to initialize the window functions, etc.
  380.  */
  381. short NAwindow(Rect *, long, char *, short, long *, long, na_initp);
  382.  
  383. /* add a new task to the task list, given pointer to task procedure, and data size
  384.  */
  385. void NAaddtask(na_taskp, long);
  386.  
  387. /* standard init procedure for an about box -- stops all background tasks, however */
  388. short NAabout(na_win*, long*);
  389.  
  390. /* standard button flash procedure used by shell for keypresses */
  391. void NAflashButton(DialogPtr, short);
  392.  
  393. /* draw the default button */
  394. void NAdefaultButton(DialogPtr);
  395.  
  396. /* re-calculate cursor region information (after changing winp->cursorRgn) */
  397. void NAcalcCursor(na_win*);
  398.  
  399. /* this saves a window's dimensions into a 'WIND' resource with appropriate resid */
  400. void NAsaveWin(na_win*);
  401.  
  402. /* This is available to access window structures other than the current window
  403.  * best for looking at parent window or child window(s).
  404.  */
  405. na_win *NAlockWindow(na_win**);
  406.  
  407. /* This is available, but the user should only call it is severe cases */
  408. short NAcloseWindow(na_win*, short);
  409.  
  410. /* this is for closing all windows, the user should only call it from main
  411.  * usually NAhead is the first parameter.
  412.  */
  413. short NAcloseWindows(na_win**, short);
  414.  
  415. /* this is for sending an event directly to the misc procedure of all windows.
  416.  * usually NAhead is the first parameter.
  417.  */
  418. short NAallWindows(na_win**, EventRecord*);
  419.  
  420.  
  421. /* niftyappclip functions:
  422.  * NAclipboardMenu: menuid, itemid, 'TEXT' or 'PICT'
  423.  * NAclipboard: true = window on, false = window off, 'TEXT' or 'PICT'
  424.  */
  425. void NAclipboardMenu(WORD, WORD, ResType);
  426. void NAclipboard(Boolean, ResType);
  427.  
  428.  
  429. /* niftyappdebug function:
  430.  */
  431. void NAdebug(char *, ...);
  432.  
  433.  
  434. /* niftyappdialog functions:
  435.  */
  436. /* select a radio button
  437.  * returns number from 0 to firstitem - lastitem: the button that's been pressed
  438.  *    DialogPtr dialog;    // the dialog window
  439.  *    short firstitem;    // the itemno of first radio button
  440.  *    short lastitem;        // the itemno of last radio button
  441.  *    short setting;        // the radio button to set (itemno to lastitem)
  442.  */
  443. short NAradioSet(DialogPtr, short, short, short);
  444.  
  445. /* get the itemno of the active radio button
  446.  *    DialogPtr dialog;    // the dialog window
  447.  *    short firstitem;    // the itemno of first radio button
  448.  *    short lastitem;        // the itemno of last radio button
  449.  */
  450. short NAradioGet(DialogPtr, short, short);
  451.  
  452. /* enable/disable,hilite,show/hide an item in a dialog window */
  453. void NAenableDItem(DialogPtr, short, Boolean);
  454. void NAhiliteDItem(DialogPtr, short, short);
  455. void NAvisibleDItem(DialogPtr, short, Boolean);
  456.  
  457. /* set/get the item text in a dialog item */
  458. void NAsetIText(DialogPtr, short, PCstr*);
  459. void NAgetIText(DialogPtr, short, PCstr*);
  460.  
  461. /* filter proc for modal dialogs which handles ESC and command-. */
  462. pascal Boolean NAfilterProc(DialogPtr, EventRecord *, short *);
  463.  
  464. /* modal loop which uses NAfilterProc */
  465. short NAmodalLoop(na_win*);
  466.  
  467. /* alert with automatic parameters from a STR# resource
  468.  * pass 0 for unused strings.  Returns item id of button hit.
  469.  * NAalertParam(alert, strlist, str1, str2, str3, str4);
  470.  */
  471. short NAalertParam(short, short, short, short, short, short);
  472.  
  473.  
  474. /* NATE (NiftyApp TextEdit) libraries
  475.  */
  476. #define NATEflags (NA_TITLEBAR | NA_GROWBOX | NA_ZOOMBOX | NA_CLOSEBOX \
  477.     | NA_HASCONTROLS | NA_HILITECTRLS)
  478. #define NATE_DEFAULT    0x00000000L
  479. #define NATE_READONLY    0x01000000L
  480. #define NATE_NOMOUSE    0x02000000L
  481. #define NATE_NOHSCROLL    0x04000000L
  482. #define NATE_NOVSCROLL    0x08000000L
  483. void NATEinit(na_win*, long, short, Ptr, long); /* winp, flags, horizwidth, data, len */
  484. short NATEinitp(na_win*, long*);
  485. short NATEmousep(na_win*, Point, short, short);
  486. short NATEidlep(na_win*);
  487. short NATEactivep(na_win*, Boolean);
  488. short NATEkeyp(na_win*, long, short);
  489. short NATEmenup(na_win*, WORD, WORD);
  490. short NATEupdatep(na_win*, Boolean);
  491. short NATEctrlp(na_win*, Point, short, short, ControlHandle);
  492. short NATEclosep(na_win*);
  493.  
  494. void NATEsetscroll(na_win*, Boolean, Rect*, Rect*);
  495. void NATEappend(na_win*, char*, long);
  496.  
  497. /* Niftyapp file library
  498.  */
  499. #define NA_FNAMELEN    65
  500. short NAsaveData(PCstr*, PCstr*, OSType, OSType);
  501. /* PCstr fname[NA_FNAMELEN];
  502.  * PCstr *prompt;
  503.  * OSType creator, ftype;
  504.  */
  505.  
  506. /* PC, C string libraries:
  507.  */
  508. #define SetClen(pcstr)    (*((pcstr) + *(pcstr) + 1) = '\0')
  509. #define PCstrlen(pcstr)    (*(pcstr))
  510. #define Pstrlen(pstr)    (* (unsigned char *) (pstr))
  511.  
  512. void PtoPCstrcpy(PCstr*, char*);
  513. void CtoPCstrcpy(PCstr*, char*);
  514. void PCtoPCstrcpy(PCstr*, PCstr*);
  515. void PtoPCstrncpy(PCstr*, char*, short);
  516. void CtoPCstrncpy(PCstr*, char*, short);
  517. void PtoPCstrcat(PCstr*, char*);
  518. void CtoPCstrcat(PCstr*, char*);
  519. PCstr *PtoPCstr(char*);
  520. PCstr *CtoPCstr(char*);
  521. void SetPlen(PCstr*);
  522. PCstr *longtoPCstr(long);
  523.